package com.skt.common_hr.common.components
{
	import flash.events.KeyboardEvent;
	import flash.ui.Keyboard;
	
	import mx.containers.Panel;
	import mx.controls.Button;
	
	public class PanelHr extends Panel{
		
		public function PanelHr()
		{
			super();
		}
		
		[Embed(source="/assets/images/btn_close_up.png")]
	    private var closeIcon:Class;
	    [Embed(source="/assets/images/btn_close_down.png")]
	    private var closeIcon_down:Class;
	    [Embed(source="/assets/images/btn_close_over.png")]
	    private var closeIcon_over:Class;
	    
		private var _closeFunc:Function = null;
		public function set closeFunc(func:Function):void{
			_closeFunc = func;
		}
		
		override protected function createChildren():void{
			super.createChildren();
			this.setStyle("paddingLeft", 5);
			this.setStyle("paddingRight", 5);
			this.setStyle("paddingTop", 5);
			this.setStyle("paddingBottom", 5);
			
		   	var closeBtn:Button = new Button();
		   	if(_closeFunc != null){
			   	closeBtn.addEventListener("click",_closeFunc);
			   	this.addEventListener(KeyboardEvent.KEY_UP, escKeyEvent);
		   	}
		    closeBtn.setStyle("upSkin",closeIcon);
		    closeBtn.setStyle("downSkin",closeIcon_down);
		    closeBtn.setStyle("overSkin",closeIcon_over);
		    closeBtn.buttonMode = true;
		   	closeBtn.setActualSize(17,17);
		   	closeBtn.x = this.width - 27;
		   	closeBtn.y = 8;

		   	rawChildren.addChild(closeBtn);
		   	this.setFocus();
		}
		
		private function escKeyEvent(event:KeyboardEvent):void{
			if(event.keyCode == Keyboard.ESCAPE){
				_closeFunc(event);
			}
		}
	}
}